<%@ page language="java" import="com.alibaba.fastjson.JSONObject" pageEncoding="UTF-8" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%--  办公用品入库信息：
        1.删除入库记录时，将库存恢复为未登记前的数据，
        2.入库登记台账中的物品已经发放的，该台账记录不可删除--%>
<%
    JSONObject jsonData = new JSONObject();
    RecordSet rs = new RecordSet();
    String ids = Util.null2String(request.getParameter("ids"));
    int succcount = 0;
    int failcount = 0;
    rs.executeQuery("select id,wpmc,isnull(sl,0) sl,isnull(ylysl,0) ylysl,djfs,isnull(ybfsl,0) ybfsl" +
            " from uf_bgyprkmx where id in ("+ids+")");
    int counts = rs.getCounts();
    while (rs.next()) {
        String id = Util.null2String(rs.getString("id"));
        String wpmc = Util.null2String(rs.getString("wpmc"));
        String djfs = Util.null2String(rs.getString("djfs"));
        int sl = Util.getIntValue(rs.getString("sl"),0);
        int ylysl = Util.getIntValue(rs.getString("ylysl"),0);
        int ybfsl = Util.getIntValue(rs.getString("ybfsl"),0);
        if ((ylysl+ybfsl)==0 && "0".equals(djfs)) {
            rs.executeUpdate("update uf_bgypkc set kc=kc-"+sl+" where mc=? ",wpmc);
            rs.executeUpdate("update uf_bgyprkmx set sfsc=0 where id=? ",id);
            succcount++;
        }else {
            failcount++;
        }

    }
    jsonData.put( "counts", counts );
    jsonData.put( "succcount", succcount );
    jsonData.put( "failcount", failcount );
    out.print( jsonData.toJSONString() );
%>






